# coding: utf-8
import datetime
from django.utils import timezone
from django.http import HttpResponse
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from Agenda.models import *
from django.contrib.auth.models import User
from django.shortcuts import render

@login_required
def home(request):
    pessoas = Pessoa.objects.all().order_by('nome')
    context = RequestContext(request, {'pessoas':pessoas})
    return render_to_response('agenda/home.html', context)


@login_required
def agenda(request):
    pessoas = Pessoa.objects.all().order_by('nome')
    context = RequestContext(request, {'pessoas':pessoas})
    return render_to_response('agenda/agenda.html', context)

@login_required
def perfil(request, perfil_id):
    pessoa = Pessoa.objects.get(pk=perfil_id)
    context = RequestContext(request, {'pessoa':pessoa})
    return render_to_response('agenda/perfil.html', context)


@login_required
def lojas(request):
    lojas = Loja.objects.all().order_by('potencia','nome')
    context = RequestContext(request, {'lojas':lojas})
    return render_to_response('agenda/lojas.html', context)

@login_required
def loja(request, loja_id):
    loja = Loja.objects.get(pk=loja_id)
    context = RequestContext(request, {'loja':loja})
    return render_to_response('agenda/loja.html', context)

